package com.ruoyi.lm.service.impl;

import java.util.List;

import com.ruoyi.common.utils.IdWorker;
import com.ruoyi.common.utils.PingYinUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.lm.mapper.LmRequiretypeMapper;
import com.ruoyi.lm.domain.LmRequiretype;
import com.ruoyi.lm.service.ILmRequiretypeService;
import com.ruoyi.common.core.text.Convert;

/**
 * 需求分类Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-09-02
 */
@Service
public class LmRequiretypeServiceImpl implements ILmRequiretypeService 
{
    @Autowired
    private LmRequiretypeMapper lmRequiretypeMapper;

    /**
     * 查询需求分类
     * 
     * @param id 需求分类ID
     * @return 需求分类
     */
    @Override
    public LmRequiretype selectLmRequiretypeById(String id)
    {
        return lmRequiretypeMapper.selectLmRequiretypeById(id);
    }

    /**
     * 查询需求分类列表
     * 
     * @param lmRequiretype 需求分类
     * @return 需求分类
     */
    @Override
    public List<LmRequiretype> selectLmRequiretypeList(LmRequiretype lmRequiretype)
    {
        return lmRequiretypeMapper.selectLmRequiretypeList(lmRequiretype);
    }

    /**
     * 新增需求分类
     * 
     * @param lmRequiretype 需求分类
     * @return 结果
     */
    @Override
    public int insertLmRequiretype(LmRequiretype lmRequiretype)
    {
        lmRequiretype.setId(IdWorker.getId());
        lmRequiretype.setRequireCode("code_"+ PingYinUtil.getPingYin(lmRequiretype.getRequireName()));
        return lmRequiretypeMapper.insertLmRequiretype(lmRequiretype);
    }

    /**
     * 修改需求分类
     * 
     * @param lmRequiretype 需求分类
     * @return 结果
     */
    @Override
    public int updateLmRequiretype(LmRequiretype lmRequiretype)
    {
        return lmRequiretypeMapper.updateLmRequiretype(lmRequiretype);
    }

    /**
     * 删除需求分类对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteLmRequiretypeByIds(String ids)
    {
        return lmRequiretypeMapper.deleteLmRequiretypeByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除需求分类信息
     * 
     * @param id 需求分类ID
     * @return 结果
     */
    @Override
    public int deleteLmRequiretypeById(String id)
    {
        return lmRequiretypeMapper.deleteLmRequiretypeById(id);
    }
}
